package ModelApplication;

import java.text.DecimalFormat;

public class Measure {

    DecimalFormat f = new DecimalFormat("##.000");

    double measureR = 0;
    double measureG = 0;
    double measureB = 0;

    public Measure() {
    }

    public Measure(double r, double g, double b) {
        setMeasure( r, g, b );
    }

    public Measure(double [] measure) {
        setMeasure( measure );
    }

    public String getMSR() {      
        double msr = measureR + measureG + measureB / 3;

        if(msr == 0) {
            return "";  
        }
        return f.format(msr);
    }

    public String getMeasureForEachColor() {
        if(measureR == 0 && measureG == 0 && measureB == 0) {
            return "";
        }
        DecimalFormat f = new DecimalFormat("##.000");
        return f.format(measureR) + ";" + f.format(measureG) + ";" + f.format(measureB);
    }

    public void setMeasure(double r, double g, double b) {
        this.measureR = r;
        this.measureG = g;
        this.measureB = b;
    }

    public void setMeasure(double [] measure) {
        this.measureR = measure[0];
        this.measureG = measure[1];
        this.measureB = measure[2];
    }

}
